// components/row-card/row-card.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    rowList: Object
  },
  /**
   * 组件的初始数据
   */
  data: {
    isDark:''
  },

  /**
   * 组件的方法列表
   */
  methods: {

    getUserInfo() {
    
      wx.getUserProfile({
        desc: "获取你的昵称、头像、地区及性别", // 不写不弹提示框
        success: res => {
        
          wx.setStorageSync('userInfo',  res.userInfo)

          wx.showToast({
            title: '登录成功'
          })
        },
        fail: res => {
          //拒绝授权
          wx.showToast({
            title: '您拒绝了授权',
            icon: 'none'
          })
          return;
        }
      })
    },

    goToBookDetailed() {

      let storageUserInfo = wx.getStorageSync('userInfo') ? wx.getStorageSync('userInfo'):null
      if (storageUserInfo==null) {
        this.getUserInfo()
      }else {
        wx.navigateTo({
          url: '/pages/bookdetailed/bookdetailed?id='+this.properties.rowList.book,
        })
      }

   
    }

  },

  lifetimes:{
    ready:function () {
    let storageDark = wx.getStorageSync('storageDark') ? wx.getStorageSync('storageDark') : false
    this.setData({
      isDark: storageDark
    })
    }
  }
})
